<style>
    .layui-form-label {
        width: 100px;
    }

    .layui-input-inline {
        width: 450px !important;
    }
</style>
<form class="layui-form" action="/config/edit">
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">设置</li>
        </ul>
        <div class="layui-tab-content">
            <!-- 网站设置 start-->
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                    <label class="layui-form-label">系统名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="system_name" value="<?= OC['system_name'] ?>"
                               placeholder="例：XX商城"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">SEO关键词</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" value="<?= OC['keywords'] ?>"
                               placeholder="请输入关键词"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">SEO描述</label>
                    <div class="layui-input-inline">
                        <textarea name="description" rows="5" placeholder="请输入描述"
                                  class="layui-textarea"><?= OC['description'] ?></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">系统后台logo</label>
                    <div class="layui-input-inline">
                        <div class="site-demo-upload">
                            <img id="backend_logo_view"
                                 src="<?= HTTP_DOMAIN_ASSETS . '/' ?><?= empty(OC['backend_logo']) ? 'logo/default.png' : OC['backend_logo'] ?>">
                            <input id="backend_logo" type="hidden" name="backend_logo"
                                   value="<?= OC['backend_logo'] ?>">
                            <div class="site-demo-upbar">
                                <input type="file" name="Assets[image]" id="demo1">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">系统ICO</label>
                    <div class="layui-input-inline">
                        <div class="site-demo-upload">
                            <img id="system_ico_view"
                                 src="<?= HTTP_DOMAIN_ASSETS . '/' ?><?= empty(OC['system_ico']) ? 'ico/default.ico' : OC['system_ico'] ?>">
                            <input id="system_ico" type="hidden" name="system_ico" value="<?= OC['system_ico'] ?>">
                            <div class="site-demo-upbar">
                                <input type="file" name="Assets[image]" id="demo2">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上午作息时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="morning_schedule" value="<?= OC['morning_schedule'] ?>"
                               placeholder="上午：9:00-12:00"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">下午作息时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="afternoon_schedule" value="<?= OC['afternoon_schedule'] ?>"
                               placeholder="下午：14:00-18:00"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">工作周期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="work_cycle" value="<?= OC['work_cycle'] ?>"
                               placeholder="周一 至 周五"
                               class="layui-input">
                    </div>
                </div>

            </div>
            <!-- 网站设置 end-->
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="<?= Yii::$app->request->csrfParam ?>"
                   value="<?= Yii::$app->request->csrfToken ?>">
            <button class="layui-btn" lay-submit lay-filter="submit-btn">立即提交</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'upload', 'layer'], function () {
        var layer = layui.layer,
            form = layui.form();
        form.on('submit(submit-btn)', function (data) {
            var loading = layer.load(0, {
                shade: <?=Yii::$app->params['layui_shade']?>,
                time: <?=Yii::$app->params['layui_time']?>});
            $.post(data.form.action, data.field, function (rs) {
                layer.msg(rs.msg);
                if (rs.code === 0) {
                    setTimeout(function () {
                        window.location.reload();
                    }, <?=Yii::$app->params['layui_set_timeout']?>);
                }
                layer.close(loading);
            }, 'json');
            return false;
        });
        layui.upload({
            url: '/up/image?token=<?=TOKEN?>&path=logo'
            , elem: '#demo1' //指定原始元素，默认直接查找class="layui-upload-file"
            , ext: 'jpeg|jpg|png'
            , method: 'post' //上传接口的http类型
            , success: function (rs) {
                document.querySelector('#backend_logo_view').src = rs.data.src;
                document.querySelector('#backend_logo').value = rs.data.path;
            }
        });
        layui.upload({
            url: '/up/image?token=<?=TOKEN?>&path=ico'
            , elem: '#demo2' //指定原始元素，默认直接查找class="layui-upload-file"
            , ext: 'ico'
            , method: 'post' //上传接口的http类型
            , success: function (rs) {
                document.querySelector('#system_ico_view').src = rs.data.src;
                document.querySelector('#system_ico').value = rs.data.path;
            }
        });

    });
</script>
